home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MACSHELL / MS1 / UTILS / ERROR.C next >
Text File  |  1992-12-02  |  6KB  |  170 lines

  1. /*
  2.  *    MacShell Source File
  3.  *
  4.  *    Copyright (c) 1989, 1990, 1991, 1992  Suick Bay Technologies.  All rights reserved.
  5.  *
  6.  *
  7.  *    RESTRICTIONS ON MacShell program and source code.
  8.  *
  9.  *    Ñ╩MacShell¬ is a product of Suick Bay Technologies and is provided for
  10.  *    restricted use by the owner of the CDROM "Disk to the future II".
  11.  *
  12.  *    Ñ╩No permission is granted for any commercial use without the written
  13.  *    consent of the Suick Bay Technologies.
  14.  *
  15.  *    Ñ╩No permission is granted for any redistribution of any kind use without
  16.  *    the written consent of the Suick Bay Technologies.
  17.  *
  18.  *    Ñ╩Permission is granted to use this for any personal noncommercial use.
  19.  *
  20.  *    Ñ╩You may not distribute source or executable code at all, nor may you 
  21.  *    distribute it with or within a commercial product without the written
  22.  *    consent of the Suick Bay Technologies.  Please send modifications to 
  23.  *    the author for inclusion in updates to the program.  Thanks.
  24.  *
  25.  *
  26.  *    MacShell¬ IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  27.  *    WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  28.  *    PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  29.  *
  30.  *    SUICK BAY TECHNOLOGIES SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  31.  *    INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY MACSHELL
  32.  *    OR ANY PART THEREOF. 
  33.  *
  34.  *    In no event will Suick Bay Technologies be liable for any lost revenue
  35.  *    or profits or other special, indirect and consequential damages, even if
  36.  *    Suick Bay Technologies has been advised of the possibility of such damages.
  37.  *
  38.  *    Suick Bay Technologies can be reached at:
  39.  *    
  40.  *    8768 Cottonwood lane
  41.  *    Maple Grove, MN 55369
  42.  *    Voice: (612) 425-7025
  43.  *    AppleLink: D5233
  44.  *    
  45.  *
  46.  *    No parts of this software may be reproduced or stored in a
  47.  *    retrieval system or transmitted in any form, or any means,
  48.  *    electronic, mechanical, photocopying, recording or otherwise,
  49.  *    without the prior written permission of Suick Bay Technologies.
  50.  *    
  51.  *    Spread the word and not the disk.
  52.  *    
  53.  *    SPK 012290    :    Initial
  54.  */
  55.  
  56. FileError( err )
  57. OsErr    err;
  58. {
  59. char    *errStr;
  60.  
  61.     if( err == noErr )
  62.         return;
  63.  
  64.     switch( err )
  65.         {
  66.         case    fsDSIntErr    :    errStr = "Internal file system error";    break;
  67.         case    volGoneErr    :    errStr = "Server volume has been disconnected.";    break;
  68.         case    wrgVolTypErr:    errStr = "Wrong volume type error [operation not supported for MFS]";    break;
  69.         case    badMovErr    :    errStr = "Move into offspring error";    break;
  70.         case    tmwdoErr    :    errStr = "No free WDCB available";    break;
  71.         case    dirNFErr    :    errStr = "Directory not found";    break;
  72.         case    wrPermErr    :    errStr = "Write permissions error";    break;
  73.         case    badMDBErr    :    errStr = "Bad master directory block";    break;
  74.         case    fsRnErr        :    errStr = "File system internal error:during rename the old entry was deleted but could not be restored.";    break;
  75.         case    extFSErr    :    errStr = "Volume in question belongs to an external fs";    break;
  76.         case    noMacDskErr    :    errStr = "Not a mac diskette (sig bytes are wrong)";    break;
  77.         case    nsDrvErr    :    errStr = "No such drive (tried to mount a bad drive num)";    break;
  78.         case    volOnLinErr    :    errStr = "Drive volume already on-line at MountVol";    break;
  79.         case    permErr        :    errStr = "Permissions error (on file open)";    break;
  80.         case    volOffLinErr:    errStr = "Volume not on line error (was Ejected)";    break;
  81.         case    gfpErr        :    errStr = "Get file position error";    break;
  82.         case    rfNumErr    :    errStr = "Refnum error";    break;
  83.         case    paramErr    :    errStr = "Error in user parameter list";    break;
  84.         case    opWrErr        :    errStr = "File already open with with write permission";    break;
  85.         case    dupFNErr    :    errStr = "Duplicate filename (rename)";    break;
  86.         case    fBsyErr        :    errStr = "File is busy (delete)";    break;
  87.         case    vLckdErr    :    errStr = "Volume is locked";    break;
  88.         case    fLckdErr    :    errStr = "File is locked";    break;
  89.         case    wPrErr        :    errStr = "Diskette is write protected.";    break;
  90.         case    fnfErr        :    errStr = "Not found";    break;
  91.         case    tmfoErr        :    errStr = "Too many files open";    break;
  92.         case    mFulErr        :    errStr = "Memory full (open) or file won't fit (load)";    break;
  93.         case    posErr        :    errStr = "Tried to position to before start of file (r/w)";    break;
  94.         case    eofErr        :    errStr = "End of file";    break;
  95.         case    fnOpnErr    :    errStr = "File not open";    break;
  96.         case    bdNamErr    :    errStr = "Bad name";    break;
  97.         case    ioErr        :    errStr = "I/O error";    break;
  98.         case    nsvErr        :    errStr = "No such volume";    break;
  99.         case    dskFulErr    :    errStr = "Disk full";    break;
  100.         case    dirFulErr    :    errStr = "Directory full";    break;
  101.         
  102.         default :    errStr = "Unknown";    break;
  103.         }
  104.         
  105.     printf( "File Error %d : %s\n", err, errStr );
  106. }
  107.  
  108. ResourceError(  err )
  109. OsErr    err;
  110. {
  111. char    *errStr;
  112.  
  113.     if( err == noErr )
  114.         return;
  115.  
  116.     switch( err )
  117.         {
  118.         case        mapReadErr        :    errStr = "map inconsistent with operation";    break;
  119.         case        resAttrErr        :    errStr = "attribute inconsistent with operation";    break;
  120.         case        rmvRefFailed    :
  121.         case        rmvResFailed    :    errStr = "RmveResource failed";    break;
  122.         case        addRefFailed    :
  123.         case        addResFailed    :    errStr = "AddResource failed";    break;
  124.         case        resFNotFound    :    errStr = "Resource file not found";    break;
  125.         case        resNotFound        :    errStr = "Resource not found";    break;
  126.         
  127.         default :    errStr = "Unknown";    break;
  128.         }
  129.         
  130.     printf( "Resource Error %d : %s\n", err, errStr );
  131. }
  132.  
  133.  
  134. MemoryError()
  135. {
  136. char    *errStr;
  137.  
  138. int        err;
  139. long    memLeft;
  140.  
  141.     err = MemError();
  142.     
  143.     switch ( err )
  144.         {
  145.         case  memFullErr    :
  146.             memLeft = FreeMem();
  147.             printf ( "memory error:    memFullErr (-108) { not enough room in heap zone }; %ld bytes remaining\n", memLeft );
  148.             break;
  149.         case  memLockedErr    :
  150.             printf ( "memory error:    memLockedErr (-117) { block is locked }\n" );
  151.             break;
  152.         case  memPurErr        :
  153.             printf ( "memory error: memPurErr (-112) { attempt to purge a locked block }\n" );
  154.             break;
  155.         case  memWZErr        :
  156.             printf ( "memory error: memWZErr (-111) { attemp to operate on a free block }\n" );
  157.             break;
  158.         case  nilHandleErr    :
  159.             printf ( "memory error:    nilHandleErr (-109) { NIL master pointer }\n" );
  160.             break;
  161.         case  noErr            :
  162.             return;
  163.             break;
  164.         default                :
  165.             printf ( "memory error: (%d)\n", err );
  166.             break;
  167.         }
  168. }
  169.  
  170.